#! /bin/sh

if [ x = x"$1" ]; then
    echo "no size" >&2
    exit 1
fi

nseed=`echo '16 * 16 * 16' | bc`
MATMUL_OPTION=
GENVEC_OPTION=
GENMAT_OPTION=
if [ x"broadcast" = x"$2" ]; then
    echo broadcast
    MATMUL_OPTION=-b
    GENVEC_OPTION=-b
fi

GENVEC_OPTION="${GENVEC_OPTION} -s $nseed"
GENMAT_OPTION="${GENMAT_OPTION} -s $nseed"

SIZE=$1

date '+@ matmul_start %Y%m%d%H%M%S'

GID_MAT=`./bin/run.sh ./mapreduce-example.jar org.sss.mapreduce.example.GenMat ${GENMAT_OPTION} $SIZE | cut -d : -f 2`
GID_VEC=`./bin/run.sh ./mapreduce-example.jar org.sss.mapreduce.example.GenVec ${GENVEC_OPTION} $SIZE | cut -d : -f 2`

echo "mut = $GID_MAT"
echo "vec = $GID_VEC"

eval time ./bin/run.sh ./mapreduce-example.jar org.sss.mapreduce.example.MatMul $MATMUL_OPTION $GID_MAT $GID_VEC $SIZE

date '+@ matmul_done %Y%m%d%H%M%S'
